<template>
  <view class="bg-white">
    <fu-custom bgColor="bg-white" :isBack="true" :isBottom="true">
      <block slot="content">{{$t('选择学校')}}</block>
      <block slot="right">
        <view class="text-df" style="color: #0181FF;" @click.stop="submit">{{$t('确定')}}</view>
      </block>
    </fu-custom>
    <view class="container">
      <view class="container-item" @click.stop="choose(item)" v-for="(item,index) in dataList" :key="index" :class="item.is_choose==1 ? 'active' : ''">
        {{item.name}}
      </view>
    </view>
  </view>
</template>

<script>
  export default{
    data(){
      return{
        dataList: [],
      }
    },
    onLoad() {
      this.getData()
    },
    methods:{
      choose(item){
        if(item.is_choose=='1'){
          item.is_choose='0'
        }else{
          item.is_choose='1'
        }
      },
      getData() {
        this.$api.post(global.apiUrls.post655b03520e496, {

        }).then(res => {
          this.dataList = res.data.data
        })
      },
      submit(){
        const chooseArr=this.dataList.filter(item=>item.is_choose=='1')
        let housingschool_id=chooseArr.map(item=>{
          return item.aid
        }).join(',')
        let housingschool_name=chooseArr.map(item=>{
          return item.name
        }).join(',')
        const chooseobj={
          housingschool_id:housingschool_id,
          housingschool_name:housingschool_name
        }
        console.log('chooseArrchooseArr',chooseobj)
        uni.$emit('school', chooseobj)
        this.$urouter.navigateBack(1);
      },
    }
  }
</script>

<style lang="scss">
  .container{
    margin-top: 30rpx;
    height: 100vh;
  }
  .container-item{
    margin-left: 32rpx;
    height: 70rpx;
    line-height: 70rpx;
    &.active{
      color: #0181FF;
    }
  }
</style>
